/* 
 * File:   Course.cpp
 * Author: Allison
 * 
 * Created on September 30, 2013, 7:26 PM
 */

#include "Course.h"
#include <sstream>

Course::Course(string courseName, int semesterHours, string days, string time) {
    this->courseName = courseName;
    this->semesterHours = semesterHours;
    this->studentsNum = 0;
    this->schedule.setDays(days);
    this->schedule.setTime(time);
}

Course::~Course() {
}

void Course::setCourseName(string courseName) {
    this->courseName = courseName;
}

string Course::getCourseName() const {
    return courseName;
}

void Course::setSemesterHours(int semesterHours) {
    this->semesterHours = semesterHours;
}

int Course::getSemesterHours() const {
    return semesterHours;
}

void Course::setStudentsNum(int studentsNum) {
    this->studentsNum = studentsNum;
}

int Course::getStudentsNum() const {
    return studentsNum;
}

void Course::setSchedule(CourseSchedule schedule) {
    this->schedule = schedule;
}

CourseSchedule Course::getSchedule() const {
    return schedule;
}

int Course::compareTo(Course other) {
        
    if (courseName == other.courseName && schedule.getDays() == other.getSchedule().getDays())
        return schedule.getTime().compare(other.getSchedule().getTime());

    if (courseName == other.courseName && schedule.getDays() != other.getSchedule().getDays())
        return courseName.compare(other.getSchedule().getDays());

    else return courseName.compare(other.courseName);
}

//toString method creates a string containing values of
//instance variables using the specified format and returns it
string Course::toString() {
    stringstream result;
    result << "\nCourse name:\t\t" << courseName << "\n" <<
            "Semester hours:\t\t" << semesterHours << "\n" <<
            "Number of students:\t" << studentsNum << "\n" <<
            "Schedule:\t\t" << schedule.getDays() << ", " << schedule.getTime() << "\n\n";

    return result.str();
}
